package com.example.gameandroid;

import org.andengine.engine.Engine;
import org.andengine.engine.camera.ZoomCamera;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.ButtonSprite;
import org.andengine.entity.sprite.ButtonSprite.OnClickListener;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.font.Font;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.texture.region.ITiledTextureRegion;
public class StartScene extends Scene{
	
	private Sprite tela;
	private ButtonSprite botao;
	
	Engine engine;
	private ITiledTextureRegion botaoJumpTexture;
	private ITiledTextureRegion botaoRestartTexture;
	private float width;
	private float height;
	private ITextureRegion mapaTexture;
	private Font font;
	private ZoomCamera camera;
	private ITextureRegion rockTexture;
	private ITextureRegion gameOverTelaTexture;
	private ITiledTextureRegion playerTexture;
	private GameBD bd;
	
	public StartScene(Engine engine, ITiledTextureRegion botaoStartTexture, ITiledTextureRegion botaoJumpTexture ,Font font, 
			ITiledTextureRegion playerTexture, ITextureRegion mapaTexture, float width,float height, ZoomCamera camera, 
			ITextureRegion rockTexture, ITextureRegion gameOverTelaTexture, ITiledTextureRegion botaoRestartTexture, GameBD bd) {
		
		this.engine = engine;
		this.botaoJumpTexture = botaoJumpTexture;
		this.botaoRestartTexture = botaoRestartTexture;
		this.width = width;
		this.height = height;
		this.mapaTexture = mapaTexture;
		this.font = font;
		this.camera = camera;
		this.rockTexture = rockTexture;
		this.gameOverTelaTexture = gameOverTelaTexture;
		this.playerTexture = playerTexture; 
		
		this.engine=engine;
		tela = new Sprite(0, 0, mapaTexture, engine.getVertexBufferObjectManager());
		attachChild(tela);
		
		OnClickListener c = new OnClickListener() {
			@Override
			public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX,float pTouchAreaLocalY) { 
				startGame();		
			}
		};
		
		botao =  new ButtonSprite(0, 0, botaoStartTexture, engine.getVertexBufferObjectManager(),c);
		botao.setPosition((camera.getWidth()/2) - (botao.getWidth()/2), (camera.getHeight()/2) - (botao.getHeight()/2));
		attachChild(botao);
		registerTouchArea(botao);	
	}
	
	public void startGame(){
		engine.setScene(new GameScene(height, width, engine, mapaTexture, botaoJumpTexture, playerTexture, camera, font,
				rockTexture, gameOverTelaTexture, botaoRestartTexture, bd));
	}
}
